<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="我的通讯录" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<script src="/js/QueryList.js"></script>
<script src="/js/popup_ext.js"></script>
<script language="javascript">
	function doNew(){
		var url="/base/PhoneBookNew.ihtm";
		ShowIframeNoScroll("通讯录",url,320,440,"refreshWin()",760,400);
	}
	function refreshWin(){
		window.location.reload(true);
	}
	function doEdit(id){
		var url="/base/PhoneBookEdit.ihtm?id="+id;
		ShowIframeNoScroll("通讯录",url,320,440,"refreshWin()",760,400);
	}
	function doDelete(id){
		ShowConfirm('确认框','确定删除吗？',340,80,"doDelAct("+id+")");
	}
	function doDelAct(id){
		if(popRetVal!=null){
			window.location="/base/PhoneBookDelete.ihtm?id="+id+"&from_url="+encodeURIComponent(window.location);
		}
	}
	function doCancel(){
		window.close();
	}
	function doGo(pageIndex){
		var searchKey=encodeURIComponent("${searchKey}");
		window.location="/base/PhoneBookList.ihtm?search_key="+searchKey+"&current_page="+pageIndex;
	}
	function doJump(pageIndex){
		if(window.event.keyCode==13){
			doGo(pageIndex);
		}
	}
	function checkSearchKey(){
		if(window.event.keyCode==13){
			doSearch();
		}
	}
	function doSearch(){
		var searchKey=encodeURIComponent(document.getElementById("search_key").value.trim());
		window.location="/base/PhoneBookList.ihtm?search_key="+searchKey;
	}
	function doSms(receiver){
		showWin(900,500,"/sms/SmsSendForm.ihtm?receiver="+encodeURIComponent(receiver));
	}
	function doMutiSms(){
		var ob_arr = document.getElementsByName("query_checkbox");
		var str="";
		for (i=0;i<ob_arr.length;i++){
			if ((ob_arr[i].checked == true)){
				if(str!=""){
					str=str+"\n";
				}
				str = str+ob_arr[i].getAttribute("phone")+"<"+ob_arr[i].getAttribute("per_name")+">";
			}
		}
		if(str!=""){
			doSms(str);
		}else{
			ShowAlert('提示框','请选择要发短信的对象',200,100);
		}
	}
	function DoubleClick(it){
	}
	function doInit(){
		//Window_Onload();
		document.getElementById("search_key").focus();
	}
</script>
</head>
<c:set var="smsFlag" value="0" />
<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';SMS_SEND_SIMP;')!=-1}"><c:set var="smsFlag" value="1" /></c:if>
<body oncontextmenu="return false" onLoad="doInit();" class="sheet" style="text-align:center;">
<div class="sheet-main" style="width:710px;text-align:left;margin:auto;">
  <div class="sheet-top">
    <div class="content">
      <h2>我的通讯录</h2>
      <p>管理自己的联系人，用于发送手机短信</p>
    </div>
  </div>
  <div class="sheet-list">
    <div class="search-business">
		 <div class="content">
	        <table width="600">
	          <tbody>
	            <tr>
	              <td  align="right">
		              <input type="text" class="TextBox" id="search_key" name="search_key" onKeyUp="checkSearchKey();" style="width:100px" value="${searchKey}" title="以联系人姓名、联系人姓名拼音字头进行模糊查询">
		              <input type="button" class="buttom search-but" value=" 查 询" onClick="doSearch();">
					  <input type="button" value=" 新 增" onClick="doNew();" class="buttom search-add" >
					  <input type="button" value=" 发短信" onClick="doMutiSms();" id="sSmsButton" name="sSmsButton" class="buttom search-sms" <c:if test="${smsFlag!='1'}">disabled="true"</c:if>>
				  </td>
	            </tr>    
	           </tbody>      
	        </table>
	      </div>
		 <%@include file="../inc/AlertMsg.jsp"%>
	     <div class="table-list">
	        <table width="100%">
	          <tr>
			  	<th width="14"><input type="checkbox" onClick="javascript:checkall(this);"></th>
				<th width="10%" >姓名</th>
				<th width="12%" >职位</th>
				<th width="23%" >公司</th>
				<th width="14%" >手机</th>
				<th width="24%" >QQ</th>
				<th width="18%" >操作</th>
			 </tr>
			<c:forEach var="item" items="${qr.list}" varStatus="i">
			<c:if test="${(i.index mod 2)==0}"><c:set var="trClass" value="query_list_data_tr1" /></c:if>
			<c:if test="${(i.index mod 2)!=0}"><c:set var="trClass" value="query_list_data_tr2" /></c:if>
			<tr class="${trClass}" index="${i.index+1}" style='cursor:pointer;' ondblclick='javascript:DoubleClick(this)' onClick='javascript:ClickCheck(this,true)' onmouseout='javascript:mouseout(this)' onmouseover='javascript:mouseover(this)'>
				<td><input type="checkbox" onClick="javascript:ClickCheck(this,true);" name='query_checkbox' value="${item.id}" per_name="<c:out value="${item.perName}" />" phone="${item.mobile}"></td>
				<td>${item.perName}</td>
				<td>${item.possie}</td>
				<td>${item.companyName}</td>
				<td><c:if test="${smsFlag=='1'}"><a href="javascript:doSms('${item.mobile}<<c:out value="${item.perName}" />>');"></c:if>${item.mobile}<c:if test="${smsFlag=='1'}"></a></c:if></td>
				<td><a href="http://wpa.qq.com/msgrd?V=1&Uin=${item.qq}&Site=eking;&Menu=no" target="_blank"><img border="0" SRC="http://wpa.qq.com/pa?p=1:${item.qq}:8" title="点击这里给我发消息">${item.qq}</a></td>
				<td>
					<a href="javascript:doEdit('${item.id}');">编辑</a>
					<a href="javascript:doDelete('${item.id}');">删除</a>
					<c:if test="${smsFlag=='1'}"><a href="javascript:doSms('${item.mobile}<<c:out value="${item.perName}" />>');"></c:if>发短信<c:if test="${smsFlag=='1'}"></a></c:if>
				</td>
			</tr>
			</c:forEach>
		</table>
		<%@include file="../inc/Pages.jsp"%>
     </div>  
   </div>  
  </div>
<div class="blank12"></blank>
</div>
</body>
</html>